package com.jeesite.modules.dataScreen.web;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeesite.modules.dataScreen.service.WaybillService;
import com.jeesite.modules.dataScreen.web.vo.Result;
import com.jeesite.modules.dataScreen.web.vo.electronic.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "安全应急相关")
@RequestMapping("/waybill")
public class WaybillApi {

    @Resource
    private WaybillService waybillService;

    @GetMapping("/electronicTrans")
    @ApiOperation("电子运单")
    public Result<List<ElectronicTransVo>> electronicTrans() {
        return Result.OK(waybillService.electronicTrans());
    }

    @GetMapping("/county")
    @ApiOperation("区域获取")
    public Result<List<String>> county() {
        return Result.OK(waybillService.county());
    }

    @GetMapping("/countyCheck")
    @ApiOperation("区域点击获取比率")
    @ApiImplicitParam(name = "county", value = "区域名称")
    public Result<CountyCheckVo> countyCheck(@RequestParam(value = "county", required = false) String county) {
        return Result.OK(waybillService.countyCheck(county));
    }

    @GetMapping("/centerTitle")
    @ApiOperation("中间三个指标接口")
    public Result<ElectronicCenterVo> centerTitle() {
        return Result.OK(waybillService.centerTitle());
    }

    @GetMapping("/ownerGw")
    @ApiOperation("高危企业数")
    public Result<List<OwnerGwVo>> ownerGw() {
        return Result.OK(waybillService.ownerGw());
    }

    @GetMapping("/ownerGwView")
    @ApiOperation("高危企业数弹窗接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "areName", value = "地区名称", required = true),
            @ApiImplicitParam(name = "pageNum", value = "当前页", defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize", value = "单页条数", defaultValue = "10")
    })
    public Result<IPage<OwnerGwViewVo>> ownerGwView(@RequestParam String areName,
                                                    @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                                    @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
        return Result.OK(waybillService.ownerGwView(pageNum, pageSize, areName));
    }

    @GetMapping("/companyTrouble")
    @ApiOperation("年度安全隐患")
    public Result<JSONObject> companyTrouble() {
        return Result.OK(waybillService.companyTrouble());
    }

    @GetMapping("/companyTroubleView")
    @ApiOperation("年度安全隐患弹窗")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "month", value = "月份", required = true),
            @ApiImplicitParam(name = "pageNum", value = "当前页", defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize", value = "单页条数", defaultValue = "10")
    })
    public Result<IPage<CompanyTroubleViewVo>> companyTroubleView(@RequestParam Integer month,
                                                                  @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                                                  @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
        return Result.OK(waybillService.companyTroubleView(pageNum, pageSize, month));
    }

    @GetMapping("/dlTrouble")
    @ApiOperation("道路危运隐患列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前页", defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize", value = "单页条数", defaultValue = "10")
    })
    public Result<IPage<TroubleDlYhVo>> dlTrouble(
            @RequestParam(required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
        return Result.OK(waybillService.dlTrouble(pageNum, pageSize));
    }

    @GetMapping("/doubleLuTrouble")
    @ApiOperation("两客一危列表")
    public Result<JSONObject> doubleLuTrouble() {
        return Result.OK(waybillService.doubleLuTrouble());
    }

    @ApiOperation("交通安全")
    @GetMapping("/troubleSecure")
    public Result<TroubleSecureVo> troubleSecure() {
        return Result.OK(waybillService.troubleSecure());
    }

    @ApiOperation("进场,装载,卸载和运输")
    @GetMapping("/unloadAndTransport")
    public Result<UnloadAndTransportVo> unloadAndTransport() {
        return Result.OK(waybillService.unloadAndTransport());
    }

    @ApiOperation("安全风险")
    @GetMapping("/securityRisk")
    @ApiImplicitParam(name = "realtime", value = "是否实时", defaultValue = "true")
    public Result<SecurityRiskVo> securityRisk(@RequestParam(defaultValue = "true") Boolean realtime) {
        return Result.OK(waybillService.securityRisk(realtime));
    }

}
